package com.weeho.dongyong.utils;

import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;

/**
 *
 * @author Administrator
 */
public class ReflectUtil<T extends Annotation> {

    public Map<T, Field> getFieldAnnontations(Class cls, Class<T> tClass) {
        Map<T, Field> map = new HashMap<>();
        Field[] fields = cls.getFields();
        if (fields != null && fields.length > 0) {
            for (Field field : fields) {
                T label = field.getAnnotation(tClass);
                if (label != null) {
                    map.put(label, field);
                }
            }
        }
        return map;
    }
}
